package com.community.web.controller.servetype;

import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.core.page.TableDataInfo;
import com.community.domain.ServeTypeEntity;
import com.community.service.ServeTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin    //跨域连接,这个必须有的,其他注解看自己项目
@Controller
@RestController
@RequestMapping("/serveType")
public class ServeTypeController extends BaseController {
    @Autowired
    private ServeTypeService serveTypeService;
    @PreAuthorize("@ss.hasPermi('serveType:serveType:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServeTypeEntity s)
    {
        startPage();
        List<ServeTypeEntity> list = serveTypeService.selectServeTypeList(s);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('serveType:serveType:add')")
    @PostMapping("/addServeType")
    public AjaxResult addServeType(@RequestBody ServeTypeEntity s)
    {

        return toAjax(serveTypeService.addServeType(s));
    }
    @PreAuthorize("@ss.hasPermi('serveType:serveType:edit')")
    @PutMapping("/updateServeType")
    public AjaxResult updateServeType(@Validated  @RequestBody ServeTypeEntity s)
    {

        return toAjax(serveTypeService.updateServeType(s));
    }
    @PreAuthorize("@ss.hasPermi('serveType:serveType:remove')")
    @DeleteMapping("{id}")
    public AjaxResult deleteServeType(@PathVariable int id)
    {
        return toAjax(serveTypeService.deleteServeType(id));
    }
    @ResponseBody
    @RequestMapping(value = "/getRegCount",method = RequestMethod.GET)  //路径名
    public AjaxResult select(ServeTypeEntity s){
        List<ServeTypeEntity> select = serveTypeService.select(s);
        return AjaxResult.success(select);

    }

}


